<?php

	// checks for the availability of a unique username
	if(isset($_REQUEST['username'])) {
	
		require_once '../../db/db.php';
		
		$username = filter_var($_REQUEST['username'], FILTER_SANITIZE_STRING);
		$sql = "SELECT username FROM users WHERE username = '" . $username . "'";
		$check = $db->query($sql)->fetchAll();
		
		if($check) {
		
			echo '<span class="error">The username <strong>' . $_REQUEST['username'] . '</strong> is already in use.</span>';
		
		}else{
		
			echo 'OK';
		
		}
	
	}

?>